import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';
import { modalActionsDefaultProps } from './defaultProps';
import type { ModalActionsOptions } from './type';

export interface ModalActionsProps extends ModalActionsOptions, HTMLAttributes<HTMLDivElement> {}

const ModalActions: FC<ModalActionsProps> = (props) => {
  const { className, ui, centered, left, basic, children, forwardedRef, ...modalActionsProps } = props;

  return createElement(
    'div',
    {
      ref: forwardedRef,
      className: classNames({ ui, centered, left, basic }, 'actions', className),
      ...modalActionsProps,
    },
    children,
  );
};

ModalActions.displayName = 'ModalActions';
ModalActions.defaultProps = modalActionsDefaultProps;

export default ModalActions;
